<template>
  <el-scrollbar>
    <el-menu
        :default-active="this.$route.path"
        router
        class="el-menu-vertical-demo"
    >
      <el-menu-item index="0" route="/">
        <el-icon><eleme /></el-icon>
        <span>全部</span>
      </el-menu-item>
      <el-menu-item
          v-for="item in produceTypeList"
          :key="item.code"
          :index="item.code"
          :route="{ path: '/farmCropsList', query: { produceType: item.code } }"
      >
        <el-icon><component :is="item.icon" /></el-icon>
        <span>{{ item.name }}</span>
      </el-menu-item>
    </el-menu>
  </el-scrollbar>
</template>

<script>
import request from "@/http/request";

export default {
  name: "HomeAside",
  data() {
    return {
      produceTypeList: [],
    }
  },
  methods: {
    getProduceType() {
      request({
        url: "/produce/getProduceType",
        method: "get",
      }).then((response) => {
        if (response.code === 200) {
          this.produceTypeList = response.data;
        } else {
          this.$tipUtil.errTip(response.msg);
        }
      })
    },
  },
  mounted() {
    this.getProduceType();
  },
}
</script>

<style scoped>

</style>